﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataLoad.iContact.WinClient
{
    public partial class frmEditPicture : Form
    {
        public frmEditPicture()
        {
            InitializeComponent();
        }

        private DLContact _contact;

        public DialogResult Show(DLContact contact)
        {
            _contact = contact;

            return ShowDialog();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter = "All Graphic Files (*.jpg, *.jpeg, *.gif, *.png)|*.jpg;*.jpeg;*.gif;*.png|All Files(*.*)|*.*";
                dlg.CheckFileExists = true;
                dlg.AddExtension = true;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    picFrame.Picture = new Bitmap(dlg.FileName);
                    picFrame.Stretched = true;
                    picFrame.FrameRectangle = new Rectangle(0, 0, 55, 56);
                }
            }
        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            _contact.Picture = null;
            DialogResult = DialogResult.OK;
            Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            _contact.Picture = new Bitmap(picFrame.GetImage());
        }
    }
}
